package com.qianfeng.controller;

import com.qianfeng.mapper.UserInfoMapper;
import com.qianfeng.model.UserInfo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.security.Security;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    /*@Autowired(required = false)
    UserInfoMapper userInfoMapper;*/
    @GetMapping("/login")
    public String login(UserInfo userInfo){
        /*List<UserInfo> userInfos = userInfoMapper.selectAll();
        for (UserInfo user:userInfos) {
            System.out.println(user);
        }*/

        System.out.println(userInfo.getUserName()+"==="+userInfo.getPassword());
        AuthenticationToken token=new UsernamePasswordToken(userInfo.getUserName(),userInfo.getPassword());
        SecurityUtils.getSubject().login(token);
        System.out.println("。。。。。。。。。。。。。。。。。。。。。");
        return "/index";
    }
}
